#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int ch[27] = { 0 };
	for (int t = 0; t < 4; t++)
	{
		char ch1[100] = { 0 };
		fgets(ch1, sizeof(ch1), stdin);
		int i = 0;
		while (ch1[i])
		{
			if (ch1[i] >= 'A' && ch1[i] <= 'Z')
			{
				ch[ch1[i] - 'A']++;
			}
			i++;
		}
	}
	//for (int i = 0; i < 26; i++)
	//{
	//	printf("%d ", ch[i]);
	//}printf("\n");
	int max = 0;
	int max_ = 0;
	do
	{
		max = 0;
		max_ = 0;
		for (int i = 0; i < 26; i++)
		{
			if (ch[i] >= max)
			{
				max = ch[i];
				max_ = i;
			}
		}
		for (int i = 0; i < max_; i++)
		{
			if (ch[i] == max)
			{
				printf("* ");
				ch[i]--;
			}
			else
			{
				printf("  ");
			}
		}printf("*\n");
		ch[max_]--;
	} while (max != 1 && max);
	for (char a = 'A'; a < 'Z'; a++)
		printf("%c ", a);
	printf("Z");
	return 0;
}